//
//  TableViewControllerPropertyList.m
//  UILbrary
//
//  Created by mac on 17/5/2.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "TableViewControllerPropertyList.h"

@interface TableViewControllerPropertyList ()
@property (nonatomic, strong) NSArray *controllers;
@end

@implementation TableViewControllerPropertyList

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.controllers.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = self.controllers[0][1];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    Class controller = NSClassFromString(self.controllers[indexPath.row][0]) ;
    UIViewController *vc = [[controller alloc] init];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (NSArray *)controllers{
    if (!_controllers) {
        _controllers =
        @[@[@"TableviewControllerDemo1",@"代码选中cell"]];
    }
    return _controllers;
}
@end
